package com.asset.dispoal.file.bank.domain.service.command;

import com.asset.dispoal.file.bank.domain.db.mapper.FileBankMapper;
import com.asset.dispoal.file.bank.dto.FileBankDetailRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import tech.mhuang.pacebox.core.ddd.BaseCommand;
import tech.mhuang.pacebox.springboot.protocol.Result;

@Component
public class FileBankDetailModifyCommand implements BaseCommand<FileBankDetailRequest, Result> {

    @Autowired
    private FileBankMapper bankMapper;

    public Result execute(FileBankDetailRequest request) {
        bankMapper.modifyDetail(request);
        if (1 == request.getChangeAmount()) {
            bankMapper.modifyAmount(request.getSurplusAmount(), request.getBankId());
        }
        return Result.ok();
    }
}
